package com.touch.workshop.ui;
import javax.swing.*;
public class MenuBar extends JMenuBar
{
	private static final long serialVersionUID = -5304440469899016058L;
	protected FileMenu FILE = new FileMenu();
	protected EditMenu EDIT = new EditMenu();
	protected HelpMenu HELP = new HelpMenu();
	protected WindowMenu WINDOW = new WindowMenu();
	
	public MenuBar()
	{
		super();
		this.add(FILE);
		this.add(EDIT);
		this.add(WINDOW);
		this.add(HELP);
		
		this.EDIT.EXPCURVE.addActionListener(Handlers.MENUBAR_HANDLER);
		this.EDIT.LEVELLIMITS.addActionListener(Handlers.MENUBAR_HANDLER);
		this.EDIT.SCRIPTEDITOR.addActionListener(Handlers.MENUBAR_HANDLER);

		this.WINDOW.LIBRARY.addActionListener(Handlers.MENUBAR_HANDLER);
		this.WINDOW.SCRIPTEDITOR.addActionListener(Handlers.MENUBAR_HANDLER);
		this.WINDOW.CLIENTLIB.addActionListener(Handlers.MENUBAR_HANDLER);
		this.WINDOW.SERVERLIB.addActionListener(Handlers.MENUBAR_HANDLER);
		
		this.FILE.NEW.CLASS.addActionListener(Handlers.MENUBAR_HANDLER);
		this.FILE.NEW.ELEMENT.addActionListener(Handlers.MENUBAR_HANDLER);
		this.FILE.NEW.NPC.addActionListener(Handlers.MENUBAR_HANDLER);
		this.FILE.CLOSE.addActionListener(Handlers.MENUBAR_HANDLER);
		this.FILE.EXPORT.CLIENT.addActionListener(Handlers.MENUBAR_HANDLER);
		this.FILE.EXPORT.LIBRARY.addActionListener(Handlers.MENUBAR_HANDLER);
		this.FILE.EXPORT.SERVER.addActionListener(Handlers.MENUBAR_HANDLER);
		this.FILE.IMPORT.CLIENT.addActionListener(Handlers.MENUBAR_HANDLER);
		this.FILE.IMPORT.LIBRARY.addActionListener(Handlers.MENUBAR_HANDLER);
		this.FILE.IMPORT.SERVER.addActionListener(Handlers.MENUBAR_HANDLER);
		this.FILE.OPEN.addActionListener(Handlers.MENUBAR_HANDLER);
		this.FILE.SAVE.addActionListener(Handlers.MENUBAR_HANDLER);
		this.FILE.SAVEAS.addActionListener(Handlers.MENUBAR_HANDLER);
		
		this.HELP.ABOUT.addActionListener(Handlers.MENUBAR_HANDLER);
		this.HELP.CONTENTS.addActionListener(Handlers.MENUBAR_HANDLER);
		this.HELP.SVN.CONFIGURE.addActionListener(Handlers.MENUBAR_HANDLER);
		this.HELP.SVN.UPDATE.addActionListener(Handlers.MENUBAR_HANDLER);
	}
	
	protected class FileMenu extends JMenu
	{
		private static final long serialVersionUID = -6545522589766592070L;
		protected NewMenu NEW = new NewMenu();
		protected JMenuItem OPEN = new JMenuItem("Open");
		protected JMenuItem CLOSE = new JMenuItem("Close");
		protected JMenuItem SAVE = new JMenuItem("Save");
		protected JMenuItem SAVEAS = new JMenuItem("Save As");
		protected ExportMenu EXPORT = new ExportMenu();
		protected ImportMenu IMPORT = new ImportMenu();
		
		protected class NewMenu extends JMenu
		{
			private static final long serialVersionUID = 8823362881742868695L;
			protected JMenuItem CLASS = new JMenuItem("Class");
			protected JMenuItem ELEMENT = new JMenuItem("Element");
			protected JMenuItem NPC = new JMenuItem("NPC");
			protected NewMenu()
			{
				super("New");
				this.add(CLASS);
				this.add(ELEMENT);
				this.add(NPC);
			}
		}
		public FileMenu()
		{
			super("File");
			this.add(NEW);
			this.add(OPEN);
			this.add(new JSeparator());
			this.add(SAVE);
			this.add(SAVEAS);
			this.add(new JSeparator());
			this.add(IMPORT);
			this.add(EXPORT);
			this.add(new JSeparator());
			this.add(CLOSE);
		}
		
		protected class ExportMenu extends JMenu
		{
			private static final long serialVersionUID = 1697647585754037544L;
			protected JMenuItem LIBRARY = new JMenuItem("Library");
			protected JMenuItem CLIENT = new JMenuItem("Client");
			protected JMenuItem SERVER = new JMenuItem("Server");
			
			public ExportMenu()
			{
				super("Export");
				this.add(LIBRARY);
				this.add(CLIENT);
				this.add(SERVER);
			}
		}
		protected class ImportMenu extends JMenu
		{
			private static final long serialVersionUID = -5747755385972594634L;
			protected JMenuItem LIBRARY = new JMenuItem("to Library");
			protected JMenuItem CLIENT = new JMenuItem("to Client");
			protected JMenuItem SERVER = new JMenuItem("to Server");
			public ImportMenu()
			{
				super("Import");
				this.add(LIBRARY);
				this.add(CLIENT);
				this.add(SERVER);
			}
		}
	}
	protected class EditMenu extends JMenu
	{
		private static final long serialVersionUID = -6340825340216667653L;
		protected JMenuItem EXPCURVE = new JMenuItem("EXP Curve");
		protected JMenuItem LEVELLIMITS = new JMenuItem("Level Limits");
		protected JMenuItem SCRIPTEDITOR = new  JMenuItem("Scrpit Editor");
		
		public EditMenu()
		{
			super("Edit");
			this.add(EXPCURVE);
			this.add(LEVELLIMITS);
			this.add(SCRIPTEDITOR);
		}
	}
	protected class WindowMenu extends JMenu
	{
		private static final long serialVersionUID = -255247510904800750L;
		protected JMenuItem LIBRARY = new JMenuItem("Library");
		protected JMenuItem SCRIPTEDITOR = new JMenuItem("Script Editor");
		protected JMenuItem CLIENTLIB = new JMenuItem("Client Library Viewer");
		protected JMenuItem SERVERLIB = new JMenuItem("Server Library Viewer");
		
		public WindowMenu()
		{
			super("Window");
			this.add(LIBRARY);
			this.add(SCRIPTEDITOR);
			this.add(CLIENTLIB);
			this.add(SERVERLIB);
		}
	}
	protected class HelpMenu extends JMenu
	{
		private static final long serialVersionUID = 8520468164876268697L;
		protected JMenuItem ABOUT = new JMenuItem("About");
		protected JMenuItem CONTENTS = new JMenuItem("Contents");
		protected SvnMenu SVN = new SvnMenu();
		
		public HelpMenu()
		{
			super("Help");
			this.add(ABOUT);
			this.add(CONTENTS);
			this.add(new JSeparator());
			this.add(SVN);
		}
		
		protected class SvnMenu extends JMenu
		{
			private static final long serialVersionUID = 4240216485551452643L;
			protected JMenuItem CONFIGURE = new JMenuItem("Configure");
			protected JMenuItem UPDATE = new JMenuItem("Update");
			
			public SvnMenu()
			{
				super("SVN");
				this.add(CONFIGURE);
				this.add(UPDATE);
			}
		}
	}
}
